<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>rrdpython</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>

<body>



<h1 id="NAME">NAME</h1>

<p>rrdpython - About the RRD Python bindings</p>

<h1 id="SYNOPSIS">SYNOPSIS</h1>

<pre><code> import rrdtool
 rrdtool.create(&#39;/tmp/test.rrd&#39;, &#39;DS:foo:GAUGE:20:0:U&#39;)</code></pre>

<h1 id="DESCRIPTION">DESCRIPTION</h1>

<p>The <b>rrdtool</b> functions are directly callable via the Python programming language. This wrapper implementation has been written from the scratch (without SWIG)</p>

<p>The API expects strings and/or a list of strings as parameters to the functions. Please refer to the other <b>rrdtool</b> documentation for functions and valid arguments.</p>

<h1 id="EXAMPLES">EXAMPLES</h1>

<h2 id="Example-1">Example 1</h2>

<pre><code> import sys
 sys.path.append(&#39;/path/to/rrdtool/lib/python2.6/site-packages/&#39;)
 import rrdtool, tempfile

 DAY = 86400
 YEAR = 365 * DAY
 fd,path = tempfile.mkstemp(&#39;.png&#39;)

 rrdtool.graph(path,
              &#39;--imgformat&#39;, &#39;PNG&#39;,
              &#39;--width&#39;, &#39;540&#39;,
              &#39;--height&#39;, &#39;100&#39;,
              &#39;--start&#39;, &quot;-%i&quot; % YEAR,
              &#39;--end&#39;, &quot;-1&quot;,
              &#39;--vertical-label&#39;, &#39;Downloads/Day&#39;,
              &#39;--title&#39;, &#39;Annual downloads&#39;,
              &#39;--lower-limit&#39;, &#39;0&#39;,
              &#39;DEF:downloads=downloads.rrd:downloads:AVERAGE&#39;,
              &#39;AREA:downloads#990033:Downloads&#39;)

 info = rrdtool.info(&#39;downloads.rrd&#39;)
 print info[&#39;last_update&#39;]
 print info[&#39;ds[downloads].minimal_heartbeat&#39;]</code></pre>

<h2 id="Example-2">Example 2</h2>

<pre><code> import sys
 sys.path.append(&#39;/path/to/rrdtool/lib/python2.6/site-packages/&#39;)
 import rrdtool

 # in real life data_sources would be populated in loop or something similar
 data_sources=[ &#39;DS:speed1:COUNTER:600:U:U&#39;,
                &#39;DS:speed2:COUNTER:600:U:U&#39;,
                &#39;DS:speed3:COUNTER:600:U:U&#39; ]

 rrdtool.create( &#39;speed.rrd&#39;,
                 &#39;--start&#39;, &#39;920804400&#39;,
                 data_sources,
                 &#39;RRA:AVERAGE:0.5:1:24&#39;,
                 &#39;RRA:AVERAGE:0.5:6:10&#39; )</code></pre>

<p>If you use the <b>site-python-install</b> make target you can drop to first sys.path.append line since the RRDtool module will be available everywhere.</p>

<p>If RRDtool runs into trouble, it will throw an exception which you might want to catch.</p>

<h1 id="SEE-ALSO">SEE ALSO</h1>

<p>rrdcreate, rrdupdate, rrdgraph, rrddump, rrdfetch, rrdtune, rrdlast, rrdxport, rrdinfo</p>

<h1 id="AUTHOR">AUTHOR</h1>

<p>Hye-Shik Chang &lt;perky@i18n.org&gt;</p>

<p>Alan Milligan &lt;alan.milligan@last-bastion.net&gt;</p>


</body>

</html>


